package com.example.bluetoothlockapp.fragment;

import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

import com.example.bluetoothlockapp.BaseActivity;
import com.example.bluetoothlockapp.MangerMainActivity;
import com.example.bluetoothlockapp.XunJianMainActivity;
import com.example.bluetoothlockapp.R;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.app.DialogFragment;
 
import android.os.Bundle;
 
 
import android.util.Log;
import android.widget.DatePicker;

@SuppressLint("NewApi")
public class DatePickerFragment extends DialogFragment implements
		DatePickerDialog.OnDateSetListener {

	public static final String TAG = "DatePickerFragment";

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		System.out.println("OperationFatherFragment--onAttach");
	}

	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		final Calendar c = Calendar.getInstance(Locale.CHINA);
		Date myDate = new Date();
		c.setTime(myDate);
		int year = c.get(Calendar.YEAR);
		int month = c.get(Calendar.MONTH);
		int day = c.get(Calendar.DAY_OF_MONTH);
		return new DatePickerDialog(getActivity(), this, year, month, day);

	}

	@Override
	public void onDateSet(DatePicker view, int year, int month, int day) {
		
		 
		 ((BaseActivity) getActivity()).SetDateComplete(view, year, month, day);

		Log.d(TAG, "year:" + year + ",month:" + month + ",day:" + day);
	}
}
